{
}
-static cairo_region_t *
-create_offset_region (const cairo_region_t *region,
- int dx,
- int dy)
-{
- cairo_region_t *result;
-
- if (region == NULL)
- return NULL;
-
- result = cairo_region_copy (region);
- cairo_region_translate (result, -dx, -dy);
-
- return result;
-}
-
static GskRenderNode *
gtk_snapshot_collect_default (GtkSnapshot *snapshot,
GtkSnapshotState *state,
static GtkSnapshotState *
gtk_snapshot_push_state (GtkSnapshot *snapshot,
char *name,
- cairo_region_t *clip,
+ const graphene_rect_t *clip,
int translate_x,
int translate_y,
GtkSnapshotCollectFunc collect_func)
state->name = name;
if (clip)
- state->clip_region = cairo_region_reference (clip);
+ {
+ state->clip = *clip;
+ state->has_clip = TRUE;
+ }
state->translate_x = translate_x;
state->translate_y = translate_y;
state->collect_func = collect_func;
static void
gtk_snapshot_state_clear (GtkSnapshotState *state)
{
- g_clear_pointer (&state->clip_region, cairo_region_destroy);
g_clear_pointer (&state->name, g_free);
}
static GtkSnapshot *
-gtk_snapshot_new_internal (gboolean record_names,
- cairo_region_t *clip,
- char *name)
+gtk_snapshot_new_internal (gboolean record_names,
+ const graphene_rect_t *clip,
+ char *name)
{
GtkSnapshot *snapshot;
{
GtkSnapshotState *parent_state;
GtkSnapshot *snapshot;
- cairo_region_t *clip;
+ graphene_rect_t c, *clip;
char *str;
if (name && parent->record_names)
str = NULL;
parent_state = gtk_snapshot_get_current_state (parent);
- clip = create_offset_region (parent_state->clip_region,
- parent_state->translate_x,
- parent_state->translate_y);
+ if (parent_state->has_clip)
+ {
+ graphene_rect_offset_r (&parent_state->clip,
+ - parent_state->translate_x,
+ - parent_state->translate_y,
+ &c);
+ clip = &c;
+ }
+ else
+ clip = NULL;
snapshot = gtk_snapshot_new_internal (parent->record_names,
clip,
str);
- if (clip)
- cairo_region_destroy (clip);
-
return snapshot;
}
gtk_snapshot_push_state (snapshot,
g_strdup (str),
- state->clip_region,
+ state->has_clip ? &state->clip : NULL,
state->translate_x,
state->translate_y,
gtk_snapshot_collect_default);
{
GtkSnapshotState *state = gtk_snapshot_get_current_state (snapshot);
char *str;
- cairo_region_t *offset_clip;
+ graphene_rect_t clip;
if (snapshot->record_names)
{
else
str = NULL;
- offset_clip = create_offset_region (state->clip_region,
- state->translate_x,
- state->translate_y);
+ if (state->has_clip)
+ graphene_rect_offset_r (&state->clip,
+ - state->translate_x,
+ - state->translate_y,
+ &clip);
state = gtk_snapshot_push_state (snapshot,
str,
- offset_clip,
+ state->has_clip ? &clip : NULL,
0, 0,
gtk_snapshot_collect_offset);
- if (offset_clip)
- cairo_region_destroy (offset_clip);
}
static GskRenderNode *
state = gtk_snapshot_push_state (snapshot,
str,
- current_state->clip_region,
+ current_state->has_clip ? ¤t_state->clip : NULL,
current_state->translate_x,
current_state->translate_y,
gtk_snapshot_collect_opacity);
state = gtk_snapshot_push_state (snapshot,
str,
- current_state->clip_region,
+ current_state->has_clip ? ¤t_state->clip : NULL,
current_state->translate_x,
current_state->translate_y,
gtk_snapshot_collect_blur);
str = NULL;
state = gtk_snapshot_push_state (snapshot,
- str,
- current_state->clip_region,
- current_state->translate_x,
- current_state->translate_y,
- gtk_snapshot_collect_color_matrix);
+ str,
+ current_state->has_clip ? ¤t_state->clip : NULL,
+ current_state->translate_x,
+ current_state->translate_y,
+ gtk_snapshot_collect_color_matrix);
graphene_matrix_init_from_matrix (&state->data.color_matrix.matrix, color_matrix);
graphene_vec4_init_from_vec4 (&state->data.color_matrix.offset, color_offset);
{
const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
GtkSnapshotState *state;
- cairo_region_t *clip = NULL;
graphene_rect_t real_child_bounds = { { 0 } };
char *str;
str = NULL;
if (child_bounds)
- {
- cairo_rectangle_int_t rect;
- graphene_rect_offset_r (child_bounds, current_state->translate_x, current_state->translate_y, &real_child_bounds);
- rectangle_init_from_graphene (&rect, &real_child_bounds);
- clip = cairo_region_create_rectangle (&rect);
- }
+ graphene_rect_offset_r (child_bounds, current_state->translate_x, current_state->translate_y, &real_child_bounds);
state = gtk_snapshot_push_state (snapshot,
str,
- clip,
+ &real_child_bounds,
current_state->translate_x,
current_state->translate_y,
gtk_snapshot_collect_repeat);
state->data.repeat.child_bounds = real_child_bounds;
current_state = state;
-
- if (clip)
- cairo_region_destroy (clip);
}
static GskRenderNode *
{
const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
GtkSnapshotState *state;
- graphene_rect_t real_bounds;
- cairo_region_t *clip;
+ graphene_rect_t clip, real_bounds;
cairo_rectangle_int_t rect;
char *str;
str = NULL;
rectangle_init_from_graphene (&rect, &real_bounds);
- if (current_state->clip_region)
- {
- clip = cairo_region_copy (current_state->clip_region);
- cairo_region_intersect_rectangle (clip, &rect);
- }
+ if (current_state->has_clip)
+ graphene_rect_intersection (¤t_state->clip, &real_bounds, &clip);
else
- {
- clip = cairo_region_create_rectangle (&rect);
- }
+ clip = real_bounds;
+
state = gtk_snapshot_push_state (snapshot,
- str,
- clip,
- current_state->translate_x,
- current_state->translate_y,
- gtk_snapshot_collect_clip);
+ str,
+ &clip,
+ current_state->translate_x,
+ current_state->translate_y,
+ gtk_snapshot_collect_clip);
state->data.clip.bounds = real_bounds;
-
- cairo_region_destroy (clip);
}
static GskRenderNode *
const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
GtkSnapshotState *state;
GskRoundedRect real_bounds;
- cairo_region_t *clip;
- cairo_rectangle_int_t rect;
+ graphene_rect_t clip;
char *str;
gsk_rounded_rect_init_copy (&real_bounds, bounds);
else
str = NULL;
- rectangle_init_from_graphene (&rect, &real_bounds.bounds);
- if (current_state->clip_region)
- {
- clip = cairo_region_copy (current_state->clip_region);
- cairo_region_intersect_rectangle (clip, &rect);
- }
+ if (current_state->has_clip)
+ graphene_rect_intersection (¤t_state->clip, &real_bounds.bounds, &clip);
else
- {
- clip = cairo_region_create_rectangle (&rect);
- }
+ clip = real_bounds.bounds;
state = gtk_snapshot_push_state (snapshot,
- str,
- clip,
- current_state->translate_x,
- current_state->translate_y,
- gtk_snapshot_collect_rounded_clip);
+ str,
+ &clip,
+ current_state->translate_x,
+ current_state->translate_y,
+ gtk_snapshot_collect_rounded_clip);
state->data.rounded_clip.bounds = real_bounds;
-
- current_state = state;
- cairo_region_destroy (clip);
}
static GskRenderNode *
state = gtk_snapshot_push_state (snapshot,
str,
- current_state->clip_region,
+ current_state->has_clip ? ¤t_state->clip : NULL,
current_state->translate_x,
current_state->translate_y,
gtk_snapshot_collect_shadow);
top_state = gtk_snapshot_push_state (snapshot,
str,
- current_state->clip_region,
+ current_state->has_clip ? ¤t_state->clip : NULL,
current_state->translate_x,
current_state->translate_y,
gtk_snapshot_collect_blend_top);
gtk_snapshot_push_state (snapshot,
g_strdup (str),
- top_state->clip_region,
+ top_state->has_clip ? &top_state->clip : NULL,
top_state->translate_x,
top_state->translate_y,
gtk_snapshot_collect_blend_bottom);
end_state = gtk_snapshot_push_state (snapshot,
str,
- current_state->clip_region,
+ current_state->has_clip ? ¤t_state->clip : NULL,
current_state->translate_x,
current_state->translate_y,
gtk_snapshot_collect_cross_fade_end);
gtk_snapshot_push_state (snapshot,
g_strdup (str),
- end_state->clip_region,
+ end_state->has_clip ? &end_state->clip : NULL,
end_state->translate_x,
end_state->translate_y,
gtk_snapshot_collect_cross_fade_start);
graphene_rect_offset_r (bounds, current_state->translate_x, current_state->translate_y, &real_bounds);
- if (current_state->clip_region)
- {
- cairo_rectangle_int_t clip_extents;
- cairo_region_get_extents (current_state->clip_region, &clip_extents);
- graphene_rect_intersection (&GRAPHENE_RECT_INIT (
- clip_extents.x,
- clip_extents.y,
- clip_extents.width,
- clip_extents.height
- ),
- &real_bounds, &real_bounds);
- }
+ if (current_state->has_clip)
+ graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds);
node = gsk_cairo_node_new (&real_bounds);
graphene_rect_offset_r (bounds, current_state->translate_x, current_state->translate_y, &real_bounds);
/* Color nodes are trivially "clippable" so we do it now */
- if (current_state->clip_region)
- {
- cairo_rectangle_int_t clip_extents;
- cairo_region_get_extents (current_state->clip_region, &clip_extents);
- graphene_rect_intersection (&GRAPHENE_RECT_INIT (
- clip_extents.x,
- clip_extents.y,
- clip_extents.width,
- clip_extents.height
- ),
- &real_bounds, &real_bounds);
- }
+ if (current_state->has_clip)
+ graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds);
node = gsk_color_node_new (color, &real_bounds);
* Returns: %TRUE if @bounds is entirely outside the clip region
*/
gboolean
-gtk_snapshot_clips_rect (GtkSnapshot *snapshot,
- const cairo_rectangle_int_t *rect)
+gtk_snapshot_clips_rect (GtkSnapshot *snapshot,
+ const graphene_rect_t *bounds)
{
const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
- cairo_rectangle_int_t offset_rect;
+ graphene_rect_t offset_rect;
- if (current_state->clip_region == NULL)
+ if (!current_state->has_clip)
return FALSE;
- offset_rect.x = rect->x + current_state->translate_x;
- offset_rect.y = rect->y + current_state->translate_y;
- offset_rect.width = rect->width;
- offset_rect.height = rect->height;
+ graphene_rect_offset_r (bounds,
+ current_state->translate_x,
+ current_state->translate_y,
+ &offset_rect);
- return cairo_region_contains_rectangle (current_state->clip_region, &offset_rect) == CAIRO_REGION_OVERLAP_OUT;
+ return !graphene_rect_intersection (&offset_rect, ¤t_state->clip, NULL);
}
/**
real_end_point.y = end_point->y + current_state->translate_y;
/* Linear gradients can be trivially clipped if we don't change the start/end points. */
- if (current_state->clip_region)
- {
- cairo_rectangle_int_t clip_extents;
-
- cairo_region_get_extents (current_state->clip_region, &clip_extents);
- graphene_rect_intersection (&GRAPHENE_RECT_INIT (
- clip_extents.x,
- clip_extents.y,
- clip_extents.width,
- clip_extents.height
- ),
- &real_bounds, &real_bounds);
- }
+ if (current_state->has_clip)
+ graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds);
node = gsk_linear_gradient_node_new (&real_bounds,
&real_start_point,
real_end_point.y = end_point->y + current_state->translate_y;
/* Repeating Linear gradients can be trivially clipped if we don't change the start/end points. */
- if (current_state->clip_region)
- {
- cairo_rectangle_int_t clip_extents;
-
- cairo_region_get_extents (current_state->clip_region, &clip_extents);
- graphene_rect_intersection (&GRAPHENE_RECT_INIT (
- clip_extents.x,
- clip_extents.y,
- clip_extents.width,
- clip_extents.height
- ),
- &real_bounds, &real_bounds);
- }
+ if (current_state->has_clip)
+ graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds);
node = gsk_repeating_linear_gradient_node_new (&real_bounds,
&real_start_point,